﻿Jxstar.currentPage = function() {
	var config = {param:{},initpage:function(page, define){},eventcfg:{}};

	var baotypeData = Jxstar.findComboData('baotype');
	var auditData = Jxstar.findComboData('audit');
	var moneytypeData = Jxstar.findComboData('moneytype');
	var planstatus2Data = Jxstar.findComboData('planstatus2');
	var projectjdData = Jxstar.findComboData('projectjd');
	var plantype2Data = Jxstar.findComboData('plantype2');
	var yesnoData = Jxstar.findComboData('yesno');
	var planyearData = Jxstar.findComboData('planyear');
	var planstatusData = Jxstar.findComboData('planstatus');

	var cols = [
	{col:{header:'计划包属性', width:28, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: baotypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: baotypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < baotypeData.length; i++) {
				if (baotypeData[i][0] == value)
					return baotypeData[i][1];
			}
		}}, field:{name:'money_plan__bao_type',type:'string'}},
	{col:{header:'记录状态', width:78, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: auditData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: auditData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < auditData.length; i++) {
				if (auditData[i][0] == value)
					return auditData[i][1];
			}
		}}, field:{name:'money_plan__audit_up',type:'string'}},
	{col:{header:'计划编号', width:107, sortable:true}, field:{name:'money_plan__plan_code',type:'string'}},
	{col:{header:'项目名称', width:172, sortable:true}, field:{name:'money_plan__plan_name',type:'string'}},
	{col:{header:'建设内容及方案', width:263, sortable:true, hidden:true}, field:{name:'money_plan__plan_desc',type:'string'}},
	{col:{header:'项目类别', width:112, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: moneytypeData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: moneytypeData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < moneytypeData.length; i++) {
				if (moneytypeData[i][0] == value)
					return moneytypeData[i][1];
			}
		}}, field:{name:'money_plan__money_type',type:'string'}},
	{col:{header:'*项目状态', width:78, sortable:true, align:'center',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatus2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: planstatus2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatus2Data.length; i++) {
				if (planstatus2Data[i][0] == value)
					return planstatus2Data[i][1];
			}
		}}, field:{name:'money_plan__plan_status2',type:'string'}},
	{col:{header:'*预计总投资(万元)', width:121, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__plan_money',type:'float'}},
	{col:{header:'*下年计划投资(万元)', width:132, sortable:true, defaultval:'0', align:'right',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.NumberField({
			decimalPrecision:6, maxLength:12, allowBlank:false
		}),renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__year_money',type:'float'}},
	{col:{header:'累计完成投资(万元)', width:138, sortable:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__sun_money',type:'float'}},
	{col:{header:'主键', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_id',type:'string'}},
	{col:{header:'申报部门ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__dept_id',type:'string'}},
	{col:{header:'立项批复金额(万元)', width:100, sortable:true, hidden:true, renderer:JxUtil.formatNumber(6)}, field:{name:'money_plan__project_money',type:'float'}},
	{col:{header:'合同金额(万元)', width:100, sortable:true, renderer:JxUtil.formatNumber(2)}, field:{name:'money_plan__money_contract',type:'float'}},
	{col:{header:'年度项目实施内容', width:184, sortable:true, editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.TextField({
			maxLength:200
		})}, field:{name:'money_plan__year_content2',type:'string'}},
	{col:{header:'*当前形象进度', width:112, sortable:true, align:'center',
		editable:true, hcss:'color:#0000ff;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: projectjdData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false, allowBlank:false,
			value: projectjdData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < projectjdData.length; i++) {
				if (projectjdData[i][0] == value)
					return projectjdData[i][1];
			}
		}}, field:{name:'money_plan__project_process',type:'string'}},
	{col:{header:'国家局项目类别', width:100, sortable:true, align:'center',
		editable:true, hcss:'color:#3039b4;',
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: plantype2Data
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: plantype2Data[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < plantype2Data.length; i++) {
				if (plantype2Data[i][0] == value)
					return plantype2Data[i][1];
			}
		}}, field:{name:'money_plan__money_type2',type:'string'}},
	{col:{header:'是否上报国家局', width:100, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__up_comp',type:'string'}},
	{col:{header:'投资计划批复文号', width:125, sortable:true}, field:{name:'money_plan__check_fileno',type:'string'}},
	{col:{header:'立项批复日期', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_checkdate',type:'date'}},
	{col:{header:'是否结转', width:64, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: yesnoData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: yesnoData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < yesnoData.length; i++) {
				if (yesnoData[i][0] == value)
					return yesnoData[i][1];
			}
		}}, field:{name:'money_plan__is_turn',type:'string'}},
	{col:{header:'预算年度', width:64, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planyearData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planyearData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planyearData.length; i++) {
				if (planyearData[i][0] == value)
					return planyearData[i][1];
			}
		}}, field:{name:'money_plan__plan_year',type:'string'}},
	{col:{header:'申报部门', width:100, sortable:true}, field:{name:'money_plan__dept_name',type:'string'}},
	{col:{header:'开工日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_sdate',type:'date'}},
	{col:{header:'竣工日期', width:100, sortable:true, hidden:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__project_edate',type:'date'}},
	{col:{header:'项目id', width:100, sortable:true, hidden:true}, field:{name:'money_plan__project_id',type:'string'}},
	{col:{header:'申报人', width:100, sortable:true}, field:{name:'money_plan__plan_user',type:'string'}},
	{col:{header:'计划状态', width:83, sortable:true, align:'center',
		editable:false,
		editor:new Ext.form.ComboBox({
			store: new Ext.data.SimpleStore({
				fields:['value','text'],
				data: planstatusData
			}),
			emptyText: jx.star.select,
			mode: 'local',
			triggerAction: 'all',
			valueField: 'value',
			displayField: 'text',
			editable:false,
			value: planstatusData[0][0]
		}),
		renderer:function(value){
			for (var i = 0; i < planstatusData.length; i++) {
				if (planstatusData[i][0] == value)
					return planstatusData[i][1];
			}
		}}, field:{name:'money_plan__plan_status',type:'string'}},
	{col:{header:'结转日期', width:100, sortable:true, renderer:function(value) {
			return value ? value.format('Y-m-d') : '';
		}}, field:{name:'money_plan__tran_date',type:'date'}},
	{col:{header:'申报人ID', width:100, sortable:true, hidden:true}, field:{name:'money_plan__plan_userid',type:'string'}}
	];
	
	config.param = {
		cols: cols,
		sorts: null,
		hasQuery: '1',
		isedit: '1',
		isshow: '1',
		funid: 'money_tran_up'
	};
	
	
	config.eventcfg = {		selPlanTran: function(){			//记录目标表格，选择记录后刷新用			var destGrid = this.grid;					//过滤条件			var where_sql = "plan_status in ('41', '42') and bao_type < '6' and dept_id like '1001%'";			var where_type = '';			var where_value = '';						//加载数据			var hdcall = function(layout) {				//显示数据				JxUtil.delay(500, function(){					var grid = layout.getComponent(1).getComponent(0);					if (!grid.isXType('grid')) {						grid = grid.getComponent(0).getComponent(0);					}					//保存目标表格					grid.destGrid = destGrid;					grid.on('beforedestroy', function(gp){						gp.destGrid = null; delete gp.destGrid;						gp = null;						return true;					});									//设置外键值					grid.fkValue = where_value;					Jxstar.loadData(grid, {where_sql:where_sql, where_value:where_value, where_type:where_type});				});			};			//显示数据			var define = Jxstar.findNode('money_complete');			Jxstar.showData({				filename: define.layout,				title: define.nodetitle,				pagetype: 'selgrid',				nodedefine: define,				callback: hdcall			});		}	};	//定义包标志列	cols[0].col.header = '';	cols[0].col.width = 28;	cols[0].col.renderer = function(val, meta, rec) {		var html = '';		var parentId = rec.get('money_plan__plan_id');		var baotype = rec.get('money_plan__bao_type');		var isturn = rec.get('money_plan__is_turn');		var imgname = 'folder' + baotype + '.gif';		if (baotype == '1' || baotype == '2') {			html = '<img src="resources/images/exp/'+ imgname +'" style="cursor:pointer;" title="点击查看子计划" '+				   'onClick="JxPm.showSubPlan(\''+ parentId +'\', \'money_tran_sub\', \''+ isturn +'\', \'money_tran_up\');"></img>';		}		return html;	};		//处理包标志，如果有子计划，则显示包标志，没有则不显示	config.initpage = function(gridNode) {		var grid = gridNode.page;				var event = gridNode.event;		event.on('beforedelete', function(ge) {			var records = ge.grid.getSelectionModel().getSelections();						for (var i = 0; i < records.length; i++) {				var deptid = records[i].get('money_plan__dept_id');				if (deptid.length > 0 && deptid.substring(0, 4) != '1001') {					JxHint.alert('不能执行此操作，您选择的记录中包含了厂内的计划，\n本功能只能新增公司本部的计划，所以也只能删除公司本部的计划！');						return false;				}			}		});	};
		
	return new Jxstar.GridNode(config);
}